package com.cxk.hr.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cxk.hr.pojo.Department;
import com.cxk.hr.pojo.Employee;
import com.cxk.hr.pojo.Overtime;
import com.cxk.hr.service.EmployeeService;
import com.cxk.hr.service.impl.EmployeeServiceImpl;

@Controller
@RequestMapping("/overtime")
public class OvertimeController {
	@Autowired
	EmployeeService employeeService = new EmployeeServiceImpl();

	/**
	 * 查看加班信息
	 * 
	 * @param id
	 * @param model
	 * @return
	 */
	@RequestMapping("/oneself/{id}/addcheck")
	public String addcheck(@PathVariable Integer id, Model model) {
		Employee employee = (Employee) employeeService.findEmpById(id);
		List<Overtime> overtime = employeeService.findAllovertime();
		model.addAttribute("overtime", overtime);
		return "oneself_overtime"; // oneself_attendance
	}

	/**
	 * 申请加班
	 * 
	 * @param model
	 * @param depar
	 * @param departmentNumber
	 * @param request
	 * @param respones
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/addwork") // 申请加班 部门所对应的员工
	public String addwork(Model model, Integer depar, String departmentNumber, HttpServletRequest request,
			HttpServletResponse respones) throws IOException {
		List<Department> depart = employeeService.findAlldept();
		model.addAttribute("depart", depart);
		respones.setCharacterEncoding("UTF-8");
		respones.setContentType("text/html;charset=UTF-8");
		return "overtime_add";
	}
}
